var main = document.querySelector("#main")

function getUrlParms(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return r[2]; return null;
}
var couponId = getUrlParms("couponId");

function inforlist() {
    let res;
    ajax({
        url: "http://chst.vip:1234/api/getcouponproduct",
        success(res) {
            res = res.result;
            // console.log(123);
            console.log(res);
            let html = "";
            res.forEach(item => {
                html += `
                    <li data-index="${item.couponProductId}">
                        <a href="">
                        <div class="up">
                            <div class="tu">${item.couponProductImg}</div>
                            <div class="message"><p class="name">${item.couponProductName}</p>
                            <p class="price">${item.couponProductPrice}</p>
                            </div>
                        </div>
                        <p>${item.couponProductTime}</p>
                        </a>
                    </li>`
            });
            main.innerHTML = html
        },
        
        data: {
            couponid: couponId,
        },
        error(err, xhr) {
            console.log(err);
        }
    })
}
inforlist()